<?php
class pembobotan_alternatif extends MY_Controller{
    function pembobotan_alternatif(){
        parent::MY_Controller();
        $this->data['title'] = 'Pembobotan Alternatif';
        $this->load->model('m_kriteria');
        $this->load->model('m_pembobotan_alternatif');
        $this->load->model('m_calon_adik_asuh');
    }
    var $data,$limit = 10;
    function index(){
        $this->get_pembobotan_alternatif();
    }
    function get_pembobotan_alternatif($offset = 0){
        $this->data['content'] = 'pembobotan_alternatif/v_pembobotan_alternatif';
        $this->data['listKriteria'] = $this->m_kriteria->getListKriteria(NULL,NULL);
        $this->data['listCalonAdikAsuh'] = $this->m_calon_adik_asuh->getListCalonAdikAsuh(NULL,NULL,NULL,'nama','asc');
        $this->data['listBobot'] = $this->m_pembobotan_alternatif->getListBobot();
        
        $this->render($this->data);
    }
    function edit_pembobotan_alternatif_form($idCalonAdikAsuh){
        $this->data['content'] = 'pembobotan_alternatif/edit_pembobotan_alternatif';
        $this->data['linkBack'] = site_url('pembobotan_alternatif/get_pembobotan_alternatif');
        $this->data['titlePage'] = "Edit Pembobotan Alternatif";
        $this->data['subLink'] = 'pembobotan_alternatif/edit_pembobotan_alternatif_proses';
        $this->data['listCalonAdikAsuh'] = $this->m_calon_adik_asuh->getCalonAdikAsuhById($idCalonAdikAsuh);
        $this->data['listBobot'] = $this->m_pembobotan_alternatif->getBobotByCalonAdikAsuh($idCalonAdikAsuh);
        
        $this->render($this->data);
    }
    function edit_pembobotan_alternatif_proses(){
        $id = $this->input->post('id');
        $bobot = $this->input->post('bobot');
        $insert = $this->m_pembobotan_alternatif->editBobotAlternatif($id,$bobot);
        if($insert == TRUE){
            $this->session->set_flashdata("message",1);
        }else{
            $this->session->set_flashdata("message",2);
        }
        redirect('pembobotan_alternatif');
    }
}
?>
